package com.itheima;


import java.util.*;

public class topic49 {
    public static Map<String, List<String>> groupAnagrams(String[] strs) {
        Map<String, List<String>> map = new HashMap<String, List<String>>();
        for(String str : strs) {
            char array[] = str.toCharArray();
            Arrays.sort(array);
            String sorted = array.toString();
            List<String> list = map.getOrDefault(sorted, new ArrayList<String>());
            list.add(str);
            map.put(sorted, list);
        }
        return map;
    }

    public static void main(String[] args) {
        String arr[] = {"eat","tea","tan","ate","nat","bat"};
//        topic02.groupAnagrams(arr);
    }
}
